package h0808;

import java.util.Scanner;

/**
  * @description 发广播
  * @author 不知名帅哥
  * @date 2024/8/8 23:58
  * @version 1.0
*/
public class SendBroadCast {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String[] matrix = sc.nextLine().split(",");
        System.out.println(getRes(matrix));
    }

    private static int getRes(String[] matrix) {
        int n=matrix.length;
        UnionFindSet set=new UnionFindSet(n);
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if (matrix[i].charAt(j)=='1'){
                    //合并
                    set.union(i,j);
                }
            }
        }
        return set.count;
    }

    // 并查集实现
    static class UnionFindSet {
        int[] fa;
        int count;

        //初始化
        public UnionFindSet(int n) {
            this.fa = new int[n];
            for (int i = 0; i < n; i++) fa[i] = i;
            this.count = n;
        }

        //找到x的祖先
        public int find(int x) {
            //如果x不是自己的祖先
            if (x!=this.fa[x]){
                this.fa[x] = find(this.fa[x]);
                return this.fa[x];
            }
            return x;
        }

        public void union(int x, int y) {
            int x_fa = this.find(x);
            int y_fa = this.find(y);
            //祖先不一样
            if (x_fa!=y_fa){
                this.fa[y_fa]=x_fa;
                this.count--;
            }
        }
    }
}
